package com.ragdollcat.thirdaicodegenerate.config;

import dev.langchain4j.model.chat.StreamingChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import lombok.Data;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * deep seek 推理模型流式配置类
 */
@Configuration
@ConfigurationProperties("langchain4j.open-ai.reasoning-streaming-chat-model")
@Data
public class ReasoningStreamingChatModelConfig {

//    @Resource
//    private AiModelMonitorListener aiModelMonitorListener;

    private String apiKey;

    private String baseUrl;

    private String modelName;

    private Boolean logRequests;

    private Boolean logResponses;

    private Integer maxTokens;

    private Double temperature;

    /**
     * bean的类型：StreamingChatModel
     * bean的名称：reasoningStreamingChatModel
     */
    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public StreamingChatModel reasoningStreamingChatModel() {
        return OpenAiStreamingChatModel.builder().
                apiKey(apiKey)
                .baseUrl(baseUrl)
                .modelName(modelName)
                .maxTokens(maxTokens)
                .logRequests(logRequests)
                .logResponses(logResponses)
                .temperature(temperature)
//                .listeners(List.of(aiModelMonitorListener))
                .build();
    }
}
